package cocurrency.threadpool;

import java.util.concurrent.*;

/**
 * Created by luzl on 4/7/2017.
 */
public class Main {
    public static void main(String[] args){
        CountDownLatch countDownLatch=new CountDownLatch(2);
        LinkedBlockingQueue<Runnable> queue=new LinkedBlockingQueue<Runnable>();
        ThreadPoolExecutor executor= new ThreadPoolExecutor(4,20,3, TimeUnit.SECONDS,queue);
        for (int i=0;i<1000;i++){
            PrintThread printThread=new PrintThread(countDownLatch, "Thread "+i);
            executor.submit(printThread);
            //new Thread(printThread).start();
        }
        try {
            Thread.currentThread().sleep(100000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        countDownLatch.countDown();
        executor.shutdown();
    }
}
